---
keywords: ""
description: "Swift documentation for 'EncodingError'"
root: "/v5.1"
layout: "default"
title: "EncodingError"
---

<div class="intro-declaration"><code class="language-swift">enum EncodingError</code></div><p>An error that occurs during the encoding of a value.</p>
<table class="standard"><tr><th id="inheritance">Inheritance</th><td><code class="inherits">Error</code></td></tr><tr><th>Nested Types</th><td><code class="nested">EncodingError.Context</code></td></tr></table><div class="discussion comment"></div><h3>Cases</h3><div id="invalidValue-1b685bbb10f2e373837ff710e45881c2" class="declaration"><a class="toggle-link" href="#comment-invalidValue-1b685bbb10f2e373837ff710e45881c2">case invalidValue</a> <span class="required">Required</span><div class="comment collapse in" id="comment-invalidValue-1b685bbb10f2e373837ff710e45881c2"><p>An indication that an encoder or its containers could not encode the
given value.</p>
<p>As associated values, this case contains the attempted value and context
for debugging.</p>
<h4>Declaration</h4><code class="language-swift">case invalidValue(: Any, : EncodingError.Context)</code></div></div>